kopia lustrzana https://github.com/c9/core
Fixes regex and tests
rodzic
973e6fc51d
commit
94c568a532
|
@ -8,7 +8,7 @@ define(function(require, exports, module) {
|
|||
"use strict";
|
||||
|
||||
var internalTestNames = ["c9test", "c9 test"];
|
||||
var regex = new RegExp(".*(" + internalTestNames.join("|") + ").*", "g");
|
||||
var regex = new RegExp("^(" + internalTestNames.join("|") + ")+");
|
||||
|
||||
function hasInternalTestName(name) {
|
||||
if (!name) return false;
|
||||
|
|
|
@ -15,13 +15,10 @@ describe("has-internal-test-name", function() {
|
|||
});
|
||||
|
||||
it("returns true when name contains c9test", function() {
|
||||
var name = "c9testjkdfkfd";
|
||||
var name = "c9testregnjkdfkfd";
|
||||
assert.equal(true, hasInternalTestName(name), "should return true when name contains c9test");
|
||||
|
||||
name = "c9test jjkdfhfkjfdh";
|
||||
assert.equal(true, hasInternalTestName(name), "should return true when name contains c9test");
|
||||
|
||||
name = " c9testjhrrj";
|
||||
name = "c9test01";
|
||||
assert.equal(true, hasInternalTestName(name), "should return true when name contains c9test");
|
||||
|
||||
name = "c9testjhrrj ffjh";
|
||||
|
@ -32,7 +29,7 @@ describe("has-internal-test-name", function() {
|
|||
var name = "c9 test dkjfdgjhfgdfk";
|
||||
assert.equal(true, hasInternalTestName(name), "should return true when name contains c9 test");
|
||||
|
||||
name = "c9 testdkjfdgjhfgdfk";
|
||||
name = "c9 test07";
|
||||
assert.equal(true, hasInternalTestName(name), "should return true when name contains c9 test");
|
||||
|
||||
name = "c9 testdkjfdgjhfgdfk";
|
||||
|
|
|
@ -13,6 +13,7 @@ define(function(require, exports, module) {
|
|||
function skipAnalytics(user) {
|
||||
if (!user) return true;
|
||||
if (user.id === -1) return true;
|
||||
|
||||
if (hasInternalTestName(user.name)) return true;
|
||||
if (hasInternalDomain(user.email)) return true;
|
||||
return false;
|
||||
|
|
|
@ -22,6 +22,25 @@ describe("skip-analytics", function() {
|
|||
assert.equal(true, skipAnalytics(user), "skipAnalytics should return true when user id is -1");
|
||||
});
|
||||
|
||||
|
||||
it("returns false when user does not have an internal test name and no email", function() {
|
||||
var user = {
|
||||
id: faker.random.uuid(),
|
||||
name: faker.name.firstName()
|
||||
};
|
||||
|
||||
assert.equal(false, skipAnalytics(user), "skipAnalytics should return false when user does not have an internal test name and no email");
|
||||
});
|
||||
|
||||
it("returns true when user has an internal test name and no email", function() {
|
||||
var user = {
|
||||
id: faker.random.uuid(),
|
||||
name: "c9test07"
|
||||
};
|
||||
|
||||
assert.equal(true, skipAnalytics(user), "skipAnalytics should return true when user has an internal test name and no email");
|
||||
});
|
||||
|
||||
it("returns false when user has no email", function() {
|
||||
var user = {
|
||||
id: faker.random.uuid()
|
||||
|
|
Ładowanie…
Reference in New Issue