Skip to content

Commit

Permalink
test: ensure tests check each property to not be a empty string (#26)
Browse files Browse the repository at this point in the history
* test: ensure test check each property to not be a empty string

* test: multi page test include checks for empty strings
  • Loading branch information
typicalninja authored Sep 1, 2024
1 parent 80fb514 commit 7112de7
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 21 deletions.
6 changes: 3 additions & 3 deletions packages/google-sr/tests/paged.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ test("Search for paged search results", async () => {
expect(result.type).toBe(ResultTypes.OrganicResult);

// verify properties are present and not empty;
expect(result.link).toBeTypeOf("string");
expect(result.description).toBeTypeOf("string");
expect(result.title).toBeTypeOf("string");
expect(result.link).to.be.a("string").and.not.empty;
expect(result.description).to.be.a("string").and.not.empty;
expect(result.title).to.be.a("string").and.not.empty;
}
}
});
36 changes: 18 additions & 18 deletions packages/google-sr/tests/result.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ test("Search for organic results (default)", async () => {
expect(result.type).toBe(ResultTypes.OrganicResult);

// verify properties are present and not empty;
expect(result.link).toBeTypeOf("string");
expect(result.description).toBeTypeOf("string");
expect(result.title).toBeTypeOf("string");
expect(result.link).to.be.a("string").and.not.empty;
expect(result.description).to.be.a("string").and.not.empty;
expect(result.title).to.be.a("string").and.not.empty;
}
});

Expand All @@ -42,11 +42,11 @@ test("Search for translation results", async () => {
for (const result of queryResult) {
expect(result.type).toBe(ResultTypes.TranslateResult);

expect(result.sourceLanguage).toBeTypeOf("string");
expect(result.sourceText).toBeTypeOf("string");
expect(result.translationLanguage).toBeTypeOf("string");
expect(result.translationText).toBeTypeOf("string");
expect(result.translationPronunciation).toBeTypeOf("string");
expect(result.sourceLanguage).to.be.a("string").and.not.empty;
expect(result.sourceText).to.be.a("string").and.not.empty;
expect(result.translationLanguage).to.be.a("string").and.not.empty;
expect(result.translationText).to.be.a("string").and.not.empty;
expect(result.translationPronunciation).to.be.a("string").and.not.empty;

Check failure on line 49 in packages/google-sr/tests/result.test.ts

View workflow job for this annotation

GitHub Actions / Main package

tests/result.test.ts > Search for translation results

AssertionError: expected '' not to be empty ❯ tests/result.test.ts:49:65
}
});

Expand All @@ -61,13 +61,13 @@ test("Search for dictionary results", async () => {
for (const result of queryResult) {
expect(result.type).toBe(ResultTypes.DictionaryResult);

expect(result.phonetic).toBeTypeOf("string");
expect(result.word).toBeTypeOf("string");
expect(result.audio).toBeTypeOf("string");
expect(result.phonetic).to.be.a("string").and.not.empty;
expect(result.word).to.be.a("string").and.not.empty;

Check failure on line 65 in packages/google-sr/tests/result.test.ts

View workflow job for this annotation

GitHub Actions / Main package

tests/result.test.ts > Search for dictionary results

AssertionError: expected '' not to be empty ❯ tests/result.test.ts:65:45
expect(result.audio).to.be.a("string").and.not.empty;

for (const definition of result.definitions) {
expect(definition[1]).toBeTypeOf("string");
expect(definition[1]).toBeTypeOf("string");
expect(definition[1]).to.be.a("string").and.not.empty;
expect(definition[1]).to.be.a("string").and.not.empty;
}
}
});
Expand All @@ -82,8 +82,8 @@ test("Search for currency results", async () => {

for (const result of queryResult) {
expect(result.type).toBe(ResultTypes.CurrencyResult);
expect(result.from).toBeTypeOf("string");
expect(result.to).toBeTypeOf("string");
expect(result.from).to.be.a("string").and.not.empty;
expect(result.to).to.be.a("string").and.not.empty;
}
});

Expand All @@ -98,8 +98,8 @@ test("Search for time results", async () => {
for (const result of queryResult) {
expect(result.type).toBe(ResultTypes.TimeResult);

expect(result.time).toBeTypeOf("string");
expect(result.location).toBeTypeOf("string");
expect(result.timeInWords).toBeTypeOf("string");
expect(result.time).to.be.a("string").and.not.empty;
expect(result.location).to.be.a("string").and.not.empty;
expect(result.timeInWords).to.be.a("string").and.not.empty;
}
});

0 comments on commit 7112de7

Please sign in to comment.