This repository has been archived by the owner on Mar 17, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5daa86a
commit 64963bc
Showing
9 changed files
with
339 additions
and
809 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,35 @@ | ||
const assert = require('assert') | ||
|
||
// eslint-disable-next-line import/no-unresolved | ||
const { create } = require('..') | ||
const handleError = require('./helpers/handleError') | ||
|
||
const postgrestClient = create({ | ||
axiosConfig: { baseURL: 'http://localhost:3000' }, | ||
}) | ||
|
||
describe('E2E: #delete()', () => { | ||
it(`should return undefined with a single item and no option`, async () => { | ||
try { | ||
await postgrestClient.post('/customers', { | ||
email: '[email protected]', | ||
name: 'Bob Marley', | ||
}) | ||
const result = await postgrestClient.eq('email', '[email protected]').delete('/customers') | ||
beforeEach(async () => { | ||
await postgrestClient.delete('/customers') | ||
}) | ||
|
||
test(`should return undefined with a single item and no option`, async () => { | ||
await postgrestClient.post('/customers', { | ||
email: '[email protected]', | ||
name: 'Bob Marley', | ||
}) | ||
const result = await postgrestClient.eq('email', '[email protected]').delete('/customers') | ||
|
||
assert.equal(result.data, undefined) | ||
} catch (err) { | ||
handleError(err) | ||
} | ||
expect(result.data).toBeUndefined() | ||
}) | ||
|
||
it(`should return undefined with a single item and no option`, async () => { | ||
try { | ||
await postgrestClient.post('/customers', { | ||
email: '[email protected]', | ||
name: 'Bob Marley', | ||
}) | ||
const result = await postgrestClient.eq('email', '[email protected]').delete('/customers', { | ||
return: 'representation', | ||
}) | ||
test(`should return undefined with a single item and { return: "representation" }`, async () => { | ||
await postgrestClient.post('/customers', { | ||
email: '[email protected]', | ||
name: 'Bob Marley', | ||
}) | ||
const result = await postgrestClient.eq('email', '[email protected]').delete('/customers', { | ||
return: 'representation', | ||
}) | ||
|
||
assert.equal(result.data.email, '[email protected]') | ||
assert.equal(result.data.name, 'Bob Marley') | ||
} catch (err) { | ||
handleError(err) | ||
} | ||
expect(result.data.email).toEqual('[email protected]') | ||
expect(result.data.name).toEqual('Bob Marley') | ||
}) | ||
}) |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,25 @@ | ||
const assert = require('assert') | ||
|
||
// eslint-disable-next-line import/no-unresolved | ||
const { create } = require('..') | ||
|
||
const postgrestClient = create({ | ||
axiosConfig: { baseURL: 'http://localhost:3000' }, | ||
}) | ||
|
||
describe('E2E: #ilike()', () => { | ||
it(`should find all the books which title contains "an" or "An"`, async () => { | ||
test(`should find all the books which title contains "an" or "An"`, async () => { | ||
const { data: result } = await postgrestClient | ||
.select('title') | ||
.select('authors(name)') | ||
.ilike('title', 'an') | ||
.orderBy('title') | ||
.get('/books') | ||
|
||
assert.equal(result.length, 3) | ||
assert.equal(result[0].title, "An Analysis of Betty Friedan's The Feminine Mystique") | ||
assert.equal(result[0].authors.name, 'Elizabeth Whitaker') | ||
assert.equal(result[1].title, 'Anna Karenina') | ||
assert.equal(result[1].authors.name, 'Leo Tolstoy') | ||
assert.equal(result[2].title, 'War and Peace') | ||
assert.equal(result[2].authors.name, 'Leo Tolstoy') | ||
expect(result.length).toEqual(3) | ||
expect(result[0].title).toEqual("An Analysis of Betty Friedan's The Feminine Mystique") | ||
expect(result[0].authors.name).toEqual('Elizabeth Whitaker') | ||
expect(result[1].title).toEqual('Anna Karenina') | ||
expect(result[1].authors.name).toEqual('Leo Tolstoy') | ||
expect(result[2].title).toEqual('War and Peace') | ||
expect(result[2].authors.name).toEqual('Leo Tolstoy') | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,36 @@ | ||
const assert = require('assert') | ||
|
||
// eslint-disable-next-line import/no-unresolved | ||
const { create } = require('..') | ||
|
||
const postgrestClient = create({ | ||
axiosConfig: { baseURL: 'http://localhost:3000' }, | ||
}) | ||
|
||
describe('E2E: #like()', () => { | ||
it(`should find all the books which title contains "u"`, async () => { | ||
test(`should find all the books which title contains "u"`, async () => { | ||
const { data: result } = await postgrestClient | ||
.select('title') | ||
.select('authors(name)') | ||
.like('title', 'u') | ||
.orderBy('title') | ||
.get('/books') | ||
|
||
assert.equal(result.length, 2) | ||
assert.equal(result[0].title, "An Analysis of Betty Friedan's The Feminine Mystique") | ||
assert.equal(result[0].authors.name, 'Elizabeth Whitaker') | ||
assert.equal(result[1].title, 'Crow Blue') | ||
assert.equal(result[1].authors.name, 'Adriana Lisboa') | ||
expect(result.length).toEqual(2) | ||
expect(result[0].title).toEqual("An Analysis of Betty Friedan's The Feminine Mystique") | ||
expect(result[0].authors.name).toEqual('Elizabeth Whitaker') | ||
expect(result[1].title).toEqual('Crow Blue') | ||
expect(result[1].authors.name).toEqual('Adriana Lisboa') | ||
}) | ||
|
||
it(`should find all the books which title contains "U"`, async () => { | ||
test(`should find all the books which title contains "U"`, async () => { | ||
const { data: result } = await postgrestClient | ||
.select('title') | ||
.select('authors(name)') | ||
.like('title', 'U') | ||
.orderBy('title') | ||
.get('/books') | ||
|
||
assert.equal(result.length, 1) | ||
assert.equal(result[0].title, 'The Unbearable Lightness of Being') | ||
assert.equal(result[0].authors.name, 'Milan Kundera') | ||
expect(result.length).toEqual(1) | ||
expect(result[0].title).toEqual('The Unbearable Lightness of Being') | ||
expect(result[0].authors.name).toEqual('Milan Kundera') | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,76 +1,62 @@ | ||
const assert = require('assert') | ||
|
||
// eslint-disable-next-line import/no-unresolved | ||
const { create } = require('..') | ||
const handleError = require('./helpers/handleError') | ||
|
||
const postgrestClient = create({ | ||
axiosConfig: { baseURL: 'http://localhost:3000' }, | ||
}) | ||
|
||
describe('E2E: #post()', () => { | ||
beforeEach(async () => { | ||
await postgrestClient.gt('id', 1).delete('/customers') | ||
await postgrestClient.delete('/customers') | ||
}) | ||
|
||
test(`should return undefined with a single item and no option`, async () => { | ||
const result = await postgrestClient.post('/customers', { | ||
email: '[email protected]', | ||
name: 'Bob Marley', | ||
}) | ||
|
||
expect(result.data).toBeUndefined() | ||
}) | ||
|
||
it(`should return undefined with a single item and no option`, async () => { | ||
try { | ||
const result = await postgrestClient.post('/customers', { | ||
test(`should return the created row with a single item and { return: "representation" }`, async () => { | ||
const result = await postgrestClient.post( | ||
'/customers', | ||
{ | ||
email: '[email protected]', | ||
name: 'Bob Marley', | ||
}) | ||
|
||
assert.equal(result.data, undefined) | ||
} catch (err) { | ||
handleError(err) | ||
} | ||
}, | ||
{ | ||
return: 'representation', | ||
}, | ||
) | ||
|
||
expect(result.data.email).toEqual('[email protected]') | ||
expect(result.data.name).toEqual('Bob Marley') | ||
}) | ||
|
||
it(`should return the created row with a single item and { return: "representation" }`, async () => { | ||
try { | ||
const result = await postgrestClient.post( | ||
'/customers', | ||
test(`should return the created rows with multiple items and { return: "representation" }`, async () => { | ||
const result = await postgrestClient.post( | ||
'/customers', | ||
[ | ||
{ | ||
email: '[email protected]', | ||
name: 'Bob Marley', | ||
}, | ||
{ | ||
return: 'representation', | ||
email: '[email protected]', | ||
name: 'Bob Sinclar', | ||
}, | ||
) | ||
|
||
assert.equal(result.data.email, '[email protected]') | ||
assert.equal(result.data.name, 'Bob Marley') | ||
} catch (err) { | ||
handleError(err) | ||
} | ||
}) | ||
|
||
it(`should return the created rows with multiple items and { return: "representation" }`, async () => { | ||
try { | ||
const result = await postgrestClient.post( | ||
'/customers', | ||
[ | ||
{ | ||
email: '[email protected]', | ||
name: 'Bob Marley', | ||
}, | ||
{ | ||
email: '[email protected]', | ||
name: 'Bob Sinclar', | ||
}, | ||
], | ||
{ | ||
return: 'representation', | ||
}, | ||
) | ||
|
||
assert.equal(result.data.length, 2) | ||
assert.equal(result.data[0].email, '[email protected]') | ||
assert.equal(result.data[0].name, 'Bob Marley') | ||
assert.equal(result.data[1].email, '[email protected]') | ||
assert.equal(result.data[1].name, 'Bob Sinclar') | ||
} catch (err) { | ||
handleError(err) | ||
} | ||
], | ||
{ | ||
return: 'representation', | ||
}, | ||
) | ||
|
||
expect(result.data.length).toEqual(2) | ||
expect(result.data[0].email).toEqual('[email protected]') | ||
expect(result.data[0].name).toEqual('Bob Marley') | ||
expect(result.data[1].email).toEqual('[email protected]') | ||
expect(result.data[1].name).toEqual('Bob Sinclar') | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
module.exports = { | ||
bail: true, | ||
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'], | ||
roots: ['<rootDir>/e2e'], | ||
verbose: true, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.