Skip to content

Commit

Permalink
add better file content
Browse files Browse the repository at this point in the history
  • Loading branch information
michael-siek committed Feb 10, 2025
1 parent 0b76791 commit 268b8d8
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions src/linter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,9 @@ describe('linter', () => {

it('should handle linter API errors', async () => {
const files = ['error.js']
readFileStub.withArgs('error.js', 'utf8').resolves('const x = 1;')
readFileStub
.withArgs('error.js', 'utf8')
.resolves('<div><h1>hello world</h1></div>')

const scope = nock(axeLinterUrl).post('/lint-source').reply(200, {
error: 'API Error'
Expand Down Expand Up @@ -207,7 +209,9 @@ describe('linter', () => {

it('should handle network errors', async () => {
const files = ['test.js']
readFileStub.withArgs('test.js', 'utf8').resolves('const x = 1;')
readFileStub
.withArgs('test.js', 'utf8')
.resolves('<div><h1>hello world</h1></div>')

const scope = nock(axeLinterUrl)
.post('/lint-source')
Expand All @@ -225,7 +229,9 @@ describe('linter', () => {

it('should handle HTTP errors', async () => {
const files = ['test.js']
readFileStub.withArgs('test.js', 'utf8').resolves('const x = 1;')
readFileStub
.withArgs('test.js', 'utf8')
.resolves('<div><h1>hello world</h1></div>')

const scope = nock(axeLinterUrl)
.post('/lint-source')
Expand All @@ -242,7 +248,9 @@ describe('linter', () => {

it('should handle malformed API responses', async () => {
const files = ['test.js']
readFileStub.withArgs('test.js', 'utf8').resolves('const x = 1;')
readFileStub
.withArgs('test.js', 'utf8')
.resolves('<div><h1>hello world</h1></div>')

const scope = nock(axeLinterUrl).post('/lint-source').reply(200, {
report: 'invalid-format'
Expand All @@ -260,7 +268,9 @@ describe('linter', () => {
it('should rethrow non-Error objects', async () => {
const files = ['test.js']

readFileStub.withArgs('test.js', 'utf8').resolves('const x = 1;')
readFileStub
.withArgs('test.js', 'utf8')
.resolves('<div><h1>hello world</h1></div>')
sandbox.replace(require('node-fetch'), 'default', fetchStub)

// Make fetch throw a non-Error object
Expand Down

0 comments on commit 268b8d8

Please sign in to comment.