Permalink
Browse files

Improve the fork tests

  • Loading branch information...
pfrazee committed Nov 20, 2018
1 parent 8c4c6d7 commit 610418bf1b0f03ea010e9c7eb3c80c0cac132a2f
Showing with 38 additions and 2 deletions.
  1. +38 −2 tests/dat-archive-web-api-test.js
@@ -360,11 +360,22 @@ test('DatArchive.create prompt=true', async t => {
})
test('DatArchive.fork prompt=false', async t => {
// create a dat
var res = await app.executeJavascript(`
DatArchive.create({ title: 'The Title', description: 'The Description', prompt: false })
`)
var datUrl = res.url
t.truthy(datUrl.startsWith('dat://'))
await app.executeJavascript(`
var archive = new DatArchive("${datUrl}")
archive.writeFile('foo.txt', 'bar', 'utf8')
`)
// start the permission prompt
mainTab.executeJavascript(`
// put the result on the window, for checking later
window.res = null
DatArchive.fork("${createdDatURL}", { description: 'The Description 2', prompt: false }).then(
DatArchive.fork("${datUrl}", { description: 'The Description 2', prompt: false }).then(
res => window.res = res,
err => window.res = err
)
@@ -380,6 +391,13 @@ test('DatArchive.fork prompt=false', async t => {
var forkedDatURL = res.url
t.truthy(forkedDatURL.startsWith('dat://'))
// check the content
var res = await mainTab.executeJavascript(`
var archive = new DatArchive("${forkedDatURL}")
archive.readFile('foo.txt')
`)
t.deepEqual(res, 'bar')
// check the dat.json
var res = await mainTab.executeJavascript(`
var archive = new DatArchive("${forkedDatURL}")
@@ -396,11 +414,22 @@ test('DatArchive.fork prompt=false', async t => {
})
test('DatArchive.fork prompt=true', async t => {
// create a dat
var res = await app.executeJavascript(`
DatArchive.create({ title: 'The Title', description: 'The Description', prompt: false })
`)
var datUrl = res.url
t.truthy(datUrl.startsWith('dat://'))
await app.executeJavascript(`
var archive = new DatArchive("${datUrl}")
archive.writeFile('foo.txt', 'bar', 'utf8')
`)
// start the prompt
mainTab.executeJavascript(`
// put the result on the window, for checking later
window.res = null
DatArchive.fork("${createdDatURL}", { description: 'The Description 2', prompt: true }).then(
DatArchive.fork("${datUrl}", { description: 'The Description 2', prompt: true }).then(
res => window.res = res,
err => window.res = err
)
@@ -416,6 +445,13 @@ test('DatArchive.fork prompt=true', async t => {
var forkedDatURL = res.url
t.truthy(forkedDatURL.startsWith('dat://'))
// check the content
var res = await mainTab.executeJavascript(`
var archive = new DatArchive("${forkedDatURL}")
archive.readFile('foo.txt')
`)
t.deepEqual(res, 'bar')
// check the dat.json
var res = await mainTab.executeJavascript(`
var archive = new DatArchive("${forkedDatURL}")

0 comments on commit 610418b

Please sign in to comment.