Skip to content

Commit

Permalink
Build module
Browse files Browse the repository at this point in the history
  • Loading branch information
passbyval committed Feb 19, 2021
1 parent faf1e57 commit 05199c1
Show file tree
Hide file tree
Showing 5 changed files with 121 additions and 18 deletions.
4 changes: 2 additions & 2 deletions dist/abstract-tester.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ export default abstract class AbstractTester {
constructor();
setPriorHtml(html: string): void;
current(): string;
next(): Diff;
next(): Promise<Diff>;
abstract fillIn(name: string, value: string): void;
abstract click(selector: Object | string): void;
protected abstract nextHtml(): string;
protected abstract nextHtml(): Promise<string>;
}
export {};
60 changes: 56 additions & 4 deletions dist/abstract-tester.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,40 @@
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
Object.defineProperty(exports, "__esModule", { value: true });
var AbstractTester = /** @class */ (function () {
function AbstractTester() {
Expand All @@ -11,10 +47,26 @@ var AbstractTester = /** @class */ (function () {
return this.priorHtml;
};
AbstractTester.prototype.next = function () {
var diffA = this.priorHtml;
var diffB = this.nextHtml();
this.priorHtml = this.nextHtml();
return { diffA: diffA, diffB: diffB };
return __awaiter(this, void 0, void 0, function () {
var diffA, diffB, _a;
return __generator(this, function (_b) {
switch (_b.label) {
case 0:
diffA = this.priorHtml;
return [4 /*yield*/, this.nextHtml()];
case 1:
diffB = _b.sent();
_a = this;
return [4 /*yield*/, this.nextHtml()];
case 2:
_a.priorHtml = _b.sent();
return [2 /*return*/, {
diffA: diffA,
diffB: diffB
}];
}
});
});
};
return AbstractTester;
}());
Expand Down
8 changes: 4 additions & 4 deletions dist/serializer.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,20 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.print = exports.test = void 0;
var jest_serializer_vue_1 = __importDefault(require("jest-serializer-vue"));
var snapshot_diff_serializer_1 = __importDefault(require("snapshot-diff-serializer"));
function test(value) {
return jest_serializer_vue_1.default.test(value) || snapshot_diff_serializer_1.default.test(value);
}
exports.test = test;
function print(value, serializer) {
var result = '';
if (jest_serializer_vue_1.default.test(value)) {
result = jest_serializer_vue_1.default.print.apply(null, arguments);
return jest_serializer_vue_1.default.print.apply(null, [value, serializer]);
}
else if (snapshot_diff_serializer_1.default.test(value)) {
result = snapshot_diff_serializer_1.default.print.apply(null, arguments);
return snapshot_diff_serializer_1.default.print.apply(null, [value, serializer]);
}
return result;
return '';
}
exports.print = print;
9 changes: 6 additions & 3 deletions dist/vue-tester.d.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
import AbstractTester from './abstract-tester';
declare type VueWrapper = {
interface VueWrapper {
html(): string;
find(selector: object | string): any;
};
vm: {
$nextTick(): Promise<void>;
};
}
export default class VueTester extends AbstractTester {
private wrapper;
constructor(wrapper: VueWrapper);
fillIn(name: string, value: string): void;
click(selector: string | object): void;
protected nextHtml(): string;
protected nextHtml(): Promise<string>;
}
export {};
58 changes: 53 additions & 5 deletions dist/vue-tester.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,53 @@
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Expand All @@ -19,7 +58,7 @@ var VueTester = /** @class */ (function (_super) {
function VueTester(wrapper) {
var _this = _super.call(this) || this;
_this.wrapper = wrapper;
_this.setPriorHtml(_this.nextHtml());
_this.setPriorHtml(wrapper.html());
return _this;
}
VueTester.prototype.fillIn = function (name, value) {
Expand All @@ -31,7 +70,16 @@ var VueTester = /** @class */ (function (_super) {
this.wrapper.find(selector).trigger('click');
};
VueTester.prototype.nextHtml = function () {
return this.wrapper.html();
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.wrapper.vm.$nextTick()];
case 1:
_a.sent();
return [2 /*return*/, this.wrapper.html()];
}
});
});
};
return VueTester;
}(abstract_tester_1.default));
Expand Down

0 comments on commit 05199c1

Please sign in to comment.