mirror of
https://github.com/marko-js/marko.git
synced 2025-12-08 19:26:05 +00:00
parser tests
This commit is contained in:
parent
62c5a1e5ee
commit
219f9cd744
13
test/autotests/parseImport/parseImport-as/expected.json
Normal file
13
test/autotests/parseImport/parseImport-as/expected.json
Normal file
@ -0,0 +1,13 @@
|
||||
[
|
||||
{
|
||||
"name": "greetings",
|
||||
"value": "require(\"./greetings\")"
|
||||
},
|
||||
{
|
||||
"name": "hi",
|
||||
"value":{
|
||||
"object": "greetings",
|
||||
"property": "hello"
|
||||
}
|
||||
}
|
||||
]
|
||||
1
test/autotests/parseImport/parseImport-as/input.txt
Normal file
1
test/autotests/parseImport/parseImport-as/input.txt
Normal file
@ -0,0 +1 @@
|
||||
import { hello as hi } from "./greetings"
|
||||
13
test/autotests/parseImport/parseImport-member/expected.json
Normal file
13
test/autotests/parseImport/parseImport-member/expected.json
Normal file
@ -0,0 +1,13 @@
|
||||
[
|
||||
{
|
||||
"name": "$",
|
||||
"value": "require(\"jquery\")"
|
||||
},
|
||||
{
|
||||
"name": "fn",
|
||||
"value": {
|
||||
"object": "$",
|
||||
"property": "fn"
|
||||
}
|
||||
}
|
||||
]
|
||||
1
test/autotests/parseImport/parseImport-member/input.txt
Normal file
1
test/autotests/parseImport/parseImport-member/input.txt
Normal file
@ -0,0 +1 @@
|
||||
import $, { fn } from "jquery"
|
||||
@ -0,0 +1,6 @@
|
||||
[
|
||||
{
|
||||
"name": "$",
|
||||
"value": "require(\"jquery\")"
|
||||
}
|
||||
]
|
||||
1
test/autotests/parseImport/parseImport-object/input.txt
Normal file
1
test/autotests/parseImport/parseImport-object/input.txt
Normal file
@ -0,0 +1 @@
|
||||
import $ from "jquery"
|
||||
37
test/parseImport-test.js
Normal file
37
test/parseImport-test.js
Normal file
@ -0,0 +1,37 @@
|
||||
'use strict';
|
||||
require('./util/patch-module');
|
||||
|
||||
var chai = require('chai');
|
||||
chai.config.includeStack = true;
|
||||
var parseFor = require('../taglibs/core/util/parseImport.js');
|
||||
var autotest = require('./autotest');
|
||||
var fs = require('fs');
|
||||
var path = require('path');
|
||||
|
||||
describe('parseImport' , function() {
|
||||
|
||||
var autoTestDir = path.join(__dirname, 'autotests/parseImport');
|
||||
|
||||
autotest.scanDir(
|
||||
autoTestDir,
|
||||
function run(dir, helpers, done) {
|
||||
let inputPath = path.join(dir, 'input.txt');
|
||||
let input = fs.readFileSync(inputPath, {encoding: 'utf8'});
|
||||
|
||||
try {
|
||||
let parsed = parseFor(input);
|
||||
helpers.compare(parsed, '.json');
|
||||
return done();
|
||||
} catch(e) {
|
||||
if (e.code === 'INVALID_FOR') {
|
||||
helpers.compare({
|
||||
error: e.message
|
||||
}, '.json');
|
||||
return done();
|
||||
} else {
|
||||
throw e;
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
});
|
||||
Loading…
x
Reference in New Issue
Block a user