From cf2c56c7061b7ed40fdd3b40a352ddb9c9b7371f Mon Sep 17 00:00:00 2001 From: alexwl Date: Tue, 2 Oct 2018 13:17:04 +0300 Subject: Initial commit --- javascript/tests/.eslintrc.js | 5 ++++ javascript/tests/acceptance/haskell-module-test.js | 28 ++++++++++++++++++ javascript/tests/acceptance/package-test.js | 23 +++++++++++++++ javascript/tests/acceptance/packages-test.js | 16 +++++++++++ javascript/tests/helpers/.gitkeep | 0 javascript/tests/index.html | 33 ++++++++++++++++++++++ javascript/tests/integration/.gitkeep | 0 javascript/tests/integration/components/.gitkeep | 0 javascript/tests/test-helper.js | 8 ++++++ 9 files changed, 113 insertions(+) create mode 100644 javascript/tests/.eslintrc.js create mode 100644 javascript/tests/acceptance/haskell-module-test.js create mode 100644 javascript/tests/acceptance/package-test.js create mode 100644 javascript/tests/acceptance/packages-test.js create mode 100644 javascript/tests/helpers/.gitkeep create mode 100644 javascript/tests/index.html create mode 100644 javascript/tests/integration/.gitkeep create mode 100644 javascript/tests/integration/components/.gitkeep create mode 100644 javascript/tests/test-helper.js (limited to 'javascript/tests') diff --git a/javascript/tests/.eslintrc.js b/javascript/tests/.eslintrc.js new file mode 100644 index 0000000..fbf2555 --- /dev/null +++ b/javascript/tests/.eslintrc.js @@ -0,0 +1,5 @@ +module.exports = { + env: { + embertest: true + } +}; diff --git a/javascript/tests/acceptance/haskell-module-test.js b/javascript/tests/acceptance/haskell-module-test.js new file mode 100644 index 0000000..939c0dd --- /dev/null +++ b/javascript/tests/acceptance/haskell-module-test.js @@ -0,0 +1,28 @@ +import { module, test } from 'qunit'; +import { visit, currentURL, find } from '@ember/test-helpers'; +import { setupApplicationTest } from 'ember-qunit'; + + +module('Acceptance | haskell-module', function(hooks) { + setupApplicationTest(hooks); + + //Test data is in 'server/mocks/packages.js' + test('visiting /package/test-package-0.1.0.0/show/app/Main.hs', async function(assert) { + await visit('/package/test-package-0.1.0.0/show/app/Main.hs'); + + assert.equal(currentURL(), '/package/test-package-0.1.0.0/show/app/Main.hs'); + + const lines = Array.from(find('tbody').children).map((tr) => { + return tr.children[1].innerText; + }); + + assert.deepEqual(lines,["module Main where", + "", + "import Lib", + "", + "main :: IO ()", + "main = someFunc", + "", + ""]); + }); +}); diff --git a/javascript/tests/acceptance/package-test.js b/javascript/tests/acceptance/package-test.js new file mode 100644 index 0000000..bdb1fef --- /dev/null +++ b/javascript/tests/acceptance/package-test.js @@ -0,0 +1,23 @@ +import { module, test } from 'qunit'; +import { visit, currentURL, find } from '@ember/test-helpers'; +import { setupApplicationTest } from 'ember-qunit'; + + +module('Acceptance | package', function(hooks) { + setupApplicationTest(hooks); + + //Test data is in 'server/mocks/packages.js' + test('visiting /package/test-package-0.1.0.0', async function(assert) { + await visit('/package/test-package-0.1.0.0'); + assert.equal(currentURL(), '/package/test-package-0.1.0.0'); + + const moduleNames = Array.from(find('ul.modules').children).map((li) => { + return [li.innerText,li.children[0].getAttribute('href')]; + }); + + assert.deepEqual(moduleNames,[["app/Main.hs","/package/test-package-0.1.0.0/show/app/Main.hs"], + ["src/Lib.hs","/package/test-package-0.1.0.0/show/src/Lib.hs"], + ["src/Types.hs","/package/test-package-0.1.0.0/show/src/Types.hs"], + ["test/Spec.hs","/package/test-package-0.1.0.0/show/test/Spec.hs"]]); + }); +}); diff --git a/javascript/tests/acceptance/packages-test.js b/javascript/tests/acceptance/packages-test.js new file mode 100644 index 0000000..4c970b1 --- /dev/null +++ b/javascript/tests/acceptance/packages-test.js @@ -0,0 +1,16 @@ +import { module, test } from 'qunit'; +import { visit, currentURL, find } from '@ember/test-helpers'; +import { setupApplicationTest } from 'ember-qunit'; + +module('Acceptance | packages', function(hooks) { + setupApplicationTest(hooks); + + //Test data is in file 'server/mocks/packages.js' + test('visiting /', async function(assert) { + await visit('/'); + assert.equal(currentURL(), '/'); + const linkToPackage = find('ul a:first-child'); + assert.equal(linkToPackage.innerText, 'test-package-0.1.0.0'); + assert.equal(linkToPackage.getAttribute('href'), '/package/test-package-0.1.0.0'); + }); +}); diff --git a/javascript/tests/helpers/.gitkeep b/javascript/tests/helpers/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/javascript/tests/index.html b/javascript/tests/index.html new file mode 100644 index 0000000..19f55cc --- /dev/null +++ b/javascript/tests/index.html @@ -0,0 +1,33 @@ + + + + + + HaskellCodeExplorer Tests + + + + {{content-for "head"}} + {{content-for "test-head"}} + + + + + + {{content-for "head-footer"}} + {{content-for "test-head-footer"}} + + + {{content-for "body"}} + {{content-for "test-body"}} + + + + + + + + {{content-for "body-footer"}} + {{content-for "test-body-footer"}} + + diff --git a/javascript/tests/integration/.gitkeep b/javascript/tests/integration/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/javascript/tests/integration/components/.gitkeep b/javascript/tests/integration/components/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/javascript/tests/test-helper.js b/javascript/tests/test-helper.js new file mode 100644 index 0000000..0382a84 --- /dev/null +++ b/javascript/tests/test-helper.js @@ -0,0 +1,8 @@ +import Application from '../app'; +import config from '../config/environment'; +import { setApplication } from '@ember/test-helpers'; +import { start } from 'ember-qunit'; + +setApplication(Application.create(config.APP)); + +start(); -- cgit v1.2.3