浏览代码

fix linter error

pull/342/head
Guillaume Vincent 8 年前
父节点
当前提交
d764325bad
共有 1 个文件被更改,包括 11 次插入11 次删除
  1. +11
    -11
      tests/form-parser.tests.js

+ 11
- 11
tests/form-parser.tests.js 查看文件

@@ -1,29 +1,29 @@
import test from 'ava';
import jsdom from 'jsdom';
import {getLoginForm, getScore, getBestByScore, getFormInfo} from '../extension/form-parser';

test('form get a score of 10 if with a Log in button', t => {
const document = require('jsdom').jsdom(`<form><button type="submit"> Log in </button></form>`);
const document = jsdom.jsdom(`<form><button type="submit"> Log in </button></form>`);
t.is(getScore(document.forms[0]), 10);
});

test('form get a score of 10 with a Sign in button', t => {
const document = require('jsdom').jsdom(`<form><button type="submit"> Sign In </button></form>`);
const document = jsdom.jsdom(`<form><button type="submit"> Sign In </button></form>`);
t.is(getScore(document.forms[0]), 10);
});

test('form get a score case insensitive', t => {
const document = require('jsdom').jsdom(`<form><button type="submit">lOg iN</button></form>`);
const document = jsdom.jsdom(`<form><button type="submit">lOg iN</button></form>`);
t.is(getScore(document.forms[0]), 10);
});

test('form get a score of 10 if input type submit', t => {
const document = require('jsdom').jsdom(`<form><input value="Log In" type="submit"/></form>`);
const document = jsdom.jsdom(`<form><input value="Log In" type="submit"/></form>`);
t.is(getScore(document.forms[0]), 10);
});


test('form get a score of 0 if form not a login or signup form', t => {
const document = require('jsdom').jsdom(`<form><input value="title" type="text"/></form>`);
const document = jsdom.jsdom(`<form><input value="title" type="text"/></form>`);
t.is(getScore(document.forms[0]), 0);
});

@@ -38,7 +38,7 @@ test('filter empty forms array', t => {
});

test('get login form', t => {
const document = require('jsdom').jsdom(`<!doctype html><html><body>
const document = jsdom.jsdom(`<!doctype html><html><body>
<form action="/signup" method="post">
<input name="user[name]" maxlength="20" placeholder="Full name" type="text">
<input name="user[email]" placeholder="Email" type="text">
@@ -59,25 +59,25 @@ test('get login form', t => {
});

test('get no form if not password field in', t => {
const document = require('jsdom').jsdom(`<!doctype html><html><body><form><input value="title" type="text"/></form></body></html>`);
const document = jsdom.jsdom(`<!doctype html><html><body><form><input value="title" type="text"/></form></body></html>`);
t.is(getLoginForm(document), null);
});

test('get usefull field in form', t => {
const document = require('jsdom').jsdom(`<form><input id="passwordField" type="password" name="password"/></form>`);
const document = jsdom.jsdom(`<form><input id="passwordField" type="password" name="password"/></form>`);
t.is(getFormInfo(document.forms[0]).passwordField, document.getElementById('passwordField'));
t.is(getFormInfo(document.forms[0]).loginField, null);
t.is(getFormInfo(document.forms[0]).button, null);
});

test('test get option fields in form', t => {
const document = require('jsdom').jsdom(`<form><input id="usernameField" type="text" name="username"/><input type="password" name="password"/><button>Cancel</button><button id="button" type="submit">Sign In</button></form>`);
const document = jsdom.jsdom(`<form><input id="usernameField" type="text" name="username"/><input type="password" name="password"/><button>Cancel</button><button id="button" type="submit">Sign In</button></form>`);
t.is(getFormInfo(document.forms[0]).loginField, document.getElementById('usernameField'));
t.is(getFormInfo(document.forms[0]).button, document.getElementById('button'));
});

test('test real form 1', t => {
const document = require('jsdom').jsdom(`<!doctype html><html><body> <form>
const document = jsdom.jsdom(`<!doctype html><html><body> <form>
<fieldset class="form-group"><p class="text-muted"> Happy to see you here again </p>
<label for="email" class="sr-only">login.email</label>
<input type="text" class="form-control" id="email" autofocus="" placeholder="Enter your email">


正在加载...
取消
保存