mirror of
https://github.com/typicode/json-server.git
synced 2025-07-28 12:43:18 +08:00
Fix lint errors
This commit is contained in:
@ -133,7 +133,7 @@ describe('cli', () => {
|
||||
|
||||
test('should use _id as foreignKeySuffix', async () => {
|
||||
const response = await request.get('/posts/1/comments')
|
||||
assert.equal(response.body.length, 1)
|
||||
assert.strictEqual(response.body.length, 1)
|
||||
})
|
||||
|
||||
test('should apply middlewares', done => {
|
||||
@ -208,7 +208,7 @@ describe('cli', () => {
|
||||
})
|
||||
|
||||
test('should save a snapshot in snapshots dir', () => {
|
||||
assert.equal(fs.readdirSync(snapshotsDir).length, 1)
|
||||
assert.strictEqual(fs.readdirSync(snapshotsDir).length, 1)
|
||||
})
|
||||
})
|
||||
|
||||
|
@ -31,7 +31,10 @@ describe('mixins', () => {
|
||||
{ name: 'comments', id: 3 }
|
||||
]
|
||||
|
||||
assert.deepEqual(_.getRemovable(db, { foreignKeySuffix: 'Id' }), expected)
|
||||
assert.deepStrictEqual(
|
||||
_.getRemovable(db, { foreignKeySuffix: 'Id' }),
|
||||
expected
|
||||
)
|
||||
})
|
||||
|
||||
test('should support custom foreignKeySuffix', () => {
|
||||
@ -40,17 +43,20 @@ describe('mixins', () => {
|
||||
{ name: 'comments', id: 3 }
|
||||
]
|
||||
|
||||
assert.deepEqual(_.getRemovable(db, { foreignKeySuffix: 'Id' }), expected)
|
||||
assert.deepStrictEqual(
|
||||
_.getRemovable(db, { foreignKeySuffix: 'Id' }),
|
||||
expected
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
describe('createId', () => {
|
||||
test('should return a new id', () => {
|
||||
assert.equal(_.createId(db.comments), 4)
|
||||
assert.strictEqual(_.createId(db.comments), 4)
|
||||
})
|
||||
|
||||
test('should return a new uuid', () => {
|
||||
assert.notEqual(_.createId(db.photos), 3)
|
||||
assert.notStrictEqual(_.createId(db.photos), 3)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
@ -110,8 +110,8 @@ describe('Server with custom foreign key', () => {
|
||||
.del('/posts/1')
|
||||
.expect({})
|
||||
.expect(200)
|
||||
assert.equal(db.posts.length, 1)
|
||||
assert.equal(db.comments.length, 1)
|
||||
assert.strictEqual(db.posts.length, 1)
|
||||
assert.strictEqual(db.comments.length, 1)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
@ -523,7 +523,7 @@ describe('Server', () => {
|
||||
.expect('Content-Type', /json/)
|
||||
.expect({ id: 3, body: 'foo', booleanValue: true, integerValue: 1 })
|
||||
.expect(201)
|
||||
assert.equal(db.posts.length, 3)
|
||||
assert.strictEqual(db.posts.length, 3)
|
||||
})
|
||||
|
||||
test('should support x-www-form-urlencoded', async () => {
|
||||
@ -535,7 +535,7 @@ describe('Server', () => {
|
||||
// x-www-form-urlencoded will convert to string
|
||||
.expect({ id: 3, body: 'foo', booleanValue: 'true', integerValue: '1' })
|
||||
.expect(201)
|
||||
assert.equal(db.posts.length, 3)
|
||||
assert.strictEqual(db.posts.length, 3)
|
||||
})
|
||||
|
||||
test('should respond with json, create a resource and generate string id', async () => {
|
||||
@ -544,7 +544,7 @@ describe('Server', () => {
|
||||
.send({ url: 'http://foo.com', postId: 1 })
|
||||
.expect('Content-Type', /json/)
|
||||
.expect(201)
|
||||
assert.equal(db.refs.length, 2)
|
||||
assert.strictEqual(db.refs.length, 2)
|
||||
})
|
||||
})
|
||||
|
||||
@ -656,8 +656,8 @@ describe('Server', () => {
|
||||
.del('/posts/1')
|
||||
.expect({})
|
||||
.expect(200)
|
||||
assert.equal(db.posts.length, 1)
|
||||
assert.equal(db.comments.length, 3)
|
||||
assert.strictEqual(db.posts.length, 1)
|
||||
assert.strictEqual(db.comments.length, 3)
|
||||
})
|
||||
|
||||
test('should respond with 404 if resource is not found', () =>
|
||||
|
@ -7,7 +7,7 @@ describe('utils', () => {
|
||||
const perPage = 2
|
||||
|
||||
test('should return first page', () => {
|
||||
assert.deepEqual(utils.getPage(array, 1, perPage), {
|
||||
assert.deepStrictEqual(utils.getPage(array, 1, perPage), {
|
||||
items: [1, 2],
|
||||
current: 1,
|
||||
first: 1,
|
||||
@ -17,7 +17,7 @@ describe('utils', () => {
|
||||
})
|
||||
|
||||
test('should return second page', () => {
|
||||
assert.deepEqual(utils.getPage(array, 2, perPage), {
|
||||
assert.deepStrictEqual(utils.getPage(array, 2, perPage), {
|
||||
items: [3, 4],
|
||||
current: 2,
|
||||
first: 1,
|
||||
@ -28,7 +28,7 @@ describe('utils', () => {
|
||||
})
|
||||
|
||||
test('should return third page (last)', () => {
|
||||
assert.deepEqual(utils.getPage(array, 3, perPage), {
|
||||
assert.deepStrictEqual(utils.getPage(array, 3, perPage), {
|
||||
items: [5],
|
||||
current: 3,
|
||||
first: 1,
|
||||
@ -38,19 +38,19 @@ describe('utils', () => {
|
||||
})
|
||||
|
||||
test('should return an empty array if page is greater than the last page', () => {
|
||||
assert.deepEqual(utils.getPage(array, 99, perPage), {
|
||||
assert.deepStrictEqual(utils.getPage(array, 99, perPage), {
|
||||
items: []
|
||||
})
|
||||
})
|
||||
|
||||
test('should return the array if perPage is greater than the array size', () => {
|
||||
assert.deepEqual(utils.getPage(array, 1, 99), {
|
||||
assert.deepStrictEqual(utils.getPage(array, 1, 99), {
|
||||
items: array
|
||||
})
|
||||
})
|
||||
|
||||
test('should return an empty array if the array is empty', () => {
|
||||
assert.deepEqual(utils.getPage([], 1, 1), {
|
||||
assert.deepStrictEqual(utils.getPage([], 1, 1), {
|
||||
items: []
|
||||
})
|
||||
})
|
||||
|
Reference in New Issue
Block a user