-
Notifications
You must be signed in to change notification settings - Fork 4
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
Showing
1 changed file
with
45 additions
and
10 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,49 @@ | ||
import { target, getLocation, urbanstatsFixture } from './test_utils' | ||
|
||
urbanstatsFixture('random', `${target}/random.html?sampleby=population&us_only=true`) | ||
const repeats = 15 | ||
|
||
test('random-usa', async (t) => { | ||
// wait for load | ||
async function assertIsArticle(t: TestController): Promise<void> { | ||
await t.expect(await getLocation()).contains('/article.html?longname=') | ||
} | ||
|
||
async function assertNoSetUniverse(t: TestController): Promise<void> { | ||
await t.expect(await getLocation()).notContains('&universe=') | ||
} | ||
|
||
async function assertNoSpecials(t: TestController): Promise<void> { | ||
const location = await getLocation() | ||
await t.expect(location).notMatch(/.*Historical\+Congressional.*/) | ||
} | ||
|
||
async function assertCorrect(t: TestController): Promise<void> { | ||
await t.wait(1000) | ||
// contains article | ||
await t.expect(getLocation()) | ||
.contains('/article.html?longname=') | ||
// location should not include &universe= | ||
await t.expect(getLocation()) | ||
.notContains('&universe=') | ||
}) | ||
console.warn(`location: ${await getLocation()}`) | ||
await assertIsArticle(t) | ||
await assertNoSetUniverse(t) | ||
await assertNoSpecials(t) | ||
} | ||
|
||
urbanstatsFixture('random-usa-by-population', `${target}/random.html?sampleby=population&us_only=true`) | ||
|
||
for (let count = 0; count < repeats; count++) { | ||
test(`random-usa-by-population-${count}`, async (t) => { | ||
await assertCorrect(t) | ||
await t.expect(await getLocation()).match(/.*USA.*/) | ||
}) | ||
} | ||
|
||
urbanstatsFixture('random-uniformly', `${target}/random.html?sampleby=uniform`) | ||
|
||
for (let count = 0; count < repeats; count++) { | ||
test(`random-uniformly-${count}`, async (t) => { | ||
await assertCorrect(t) | ||
}) | ||
} | ||
|
||
urbanstatsFixture('random-by-population', `${target}/random.html?sampleby=population`) | ||
|
||
for (let count = 0; count < repeats; count++) { | ||
test(`random-by-population-${count}`, async (t) => { | ||
await assertCorrect(t) | ||
}) | ||
} |