Skip to content

Commit

Permalink
test: use database.properties.propertiesByScheme
Browse files Browse the repository at this point in the history
  • Loading branch information
younho9 committed Nov 20, 2021
1 parent 6282501 commit b31702e
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 26 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
"@babel/preset-typescript": "7.16.0",
"@commitlint/cli": "13.2.1",
"@commitlint/config-conventional": "13.2.0",
"@narkdown/notion-faker": "0.4.1",
"@narkdown/notion-faker": "0.5.0",
"@tsconfig/node12": "1.0.9",
"@types/faker": "5.5.9",
"@types/jest": "27.0.2",
Expand Down
32 changes: 16 additions & 16 deletions test/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ dotenv.config();

const NOTION_API_KEY = process.env.NOTION_API_KEY!;
const ENTRY_POINT_PAGE_ID = process.env.ENTRY_POINT_PAGE_ID!;
const EXAMPLE_DATABASE = process.env.EXAMPLE_DATABASE!;
const narkdown: NarkdownClient = new NarkdownClient({auth: NOTION_API_KEY});
const notionFaker: NotionFaker = new NotionFaker();
const ROW_COUNT = 200;
Expand All @@ -30,30 +31,29 @@ beforeAll(async () => {

TEST_PAGE_ID = testPageId;

const {properties: scheme} = await narkdown.databases.retrieve({
database_id: EXAMPLE_DATABASE,
});

const {id: testDatabaseId} = await narkdown.databases.create({
parent: {
page_id: TEST_PAGE_ID,
},
title: notionFaker.database.title()()(),
properties: {
title: notionFaker.database.properties.title(),
},
properties: notionFaker.database.properties.propertiesByScheme(scheme),
icon: notionFaker.icon.emoji(),
cover: notionFaker.cover('image.image')(),
});

TEST_DATABASE_ID = testDatabaseId;

await Promise.all(
Array.from({
length: ROW_COUNT,
}).map(async () =>
narkdown.pages.create({
parent: {database_id: TEST_DATABASE_ID},
properties: {
title: notionFaker.page.properties.title('address.cityName')()(),
},
}),
),
);
// eslint-disable-next-line @typescript-eslint/no-unused-vars
for (const _ of Array.from({length: ROW_COUNT})) {
// eslint-disable-next-line no-await-in-loop
await narkdown.pages.create({
parent: {database_id: TEST_DATABASE_ID},
properties: notionFaker.page.properties.propertiesByScheme(scheme),
});
}

response = await narkdown.unlimited.databases.queryAll({
database_id: TEST_DATABASE_ID,
Expand Down
18 changes: 9 additions & 9 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1356,14 +1356,14 @@
"@types/yargs" "^16.0.0"
chalk "^4.0.0"

"@narkdown/notion-faker@0.4.1":
version "0.4.1"
resolved "https://registry.yarnpkg.com/@narkdown/notion-faker/-/notion-faker-0.4.1.tgz#ca155b54193290592fb63bdecc6d754ea21212e1"
integrity sha512-gfj4Xl/rhXec3i+G1eDmvv+lnY/C4oK54w2GPu2V6IHXzI1ovILzzMXFA9s5QVdNqprqxvlXmYtyK1NEaXZL2Q==
"@narkdown/notion-faker@0.5.0":
version "0.5.0"
resolved "https://registry.yarnpkg.com/@narkdown/notion-faker/-/notion-faker-0.5.0.tgz#e9fe75923aed0440a50933e42fb0e4ba6cf85df1"
integrity sha512-XZAjU+WffB2clYCZwPvmoq9vsvL2Ecoix+Ij/gUmPArZDj+pTDTyHrLikkUFc4Y7MRKlUcSNtp5+mux+8jzdgA==
dependencies:
"@notionhq/client" "0.4.4"
"@types/faker" "5.5.9"
"@younho9/types" "0.11.2"
"@younho9/types" "0.13.0"
faker "5.5.3"
lodash.get "4.4.2"
type-fest "2.5.1"
Expand Down Expand Up @@ -1681,10 +1681,10 @@
dependencies:
"@types/prettier" "2.4.1"

"@younho9/types@0.11.2":
version "0.11.2"
resolved "https://registry.yarnpkg.com/@younho9/types/-/types-0.11.2.tgz#d84708fee54fe7d4f733ed4afab046258564ed16"
integrity sha512-6GbB1B7S51a+OBWTKjQGTemBCgkQ0HDlGpoSvZRpCHYZAou/ByxBi7iiHbM8+G1N4eKiAt0K1MIBwcJ5qS8SCw==
"@younho9/types@0.13.0":
version "0.13.0"
resolved "https://registry.yarnpkg.com/@younho9/types/-/types-0.13.0.tgz#8901fa377abdec891b97cf1d962e621de73adcc5"
integrity sha512-A1yDlaNxtGEtwiJXiyMeaX+gaC5hBdQTBk2vmRvIM+oJx80G/I0v6RwNsDsdFJAsJVm6eljp6gBGKc1QgZyvjQ==
dependencies:
tsd "0.18.0"
type-fest "2.5.1"
Expand Down

0 comments on commit b31702e

Please sign in to comment.