Package init

This commit is contained in:
lei_ju 2020-08-31 10:35:52 +08:00
parent 965b983188
commit f12d6f51d4
8 changed files with 202 additions and 0 deletions

View File

@ -0,0 +1,35 @@
From 4530bd14e6cf7be1048a5dca98cf7611fd50263e Mon Sep 17 00:00:00 2001
From: Stephen Gallagher <sgallagh@redhat.com>
Date: Mon, 5 Dec 2016 15:55:34 -0500
Subject: [PATCH] Update expected test values
Signed-off-by: Stephen Gallagher <sgallagh@redhat.com>
---
test/expect.js | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/test/expect.js b/test/expect.js
index f89563d3624af0cd1daf071122c15fadfa2a5225..97628208fae8c53e8c37ad6250526e5f1e09f883 100644
--- a/test/expect.js
+++ b/test/expect.js
@@ -147,15 +147,15 @@ describe('expect', function () {
expect(5).to.throwException();
}, 'expected 5 to be a function');
err(function () {
expect(anonItThrows).not.to.throwException();
- }, 'expected fn not to throw an exception');
+ }, 'expected anonItThrows not to throw an exception');
err(function () {
expect(anonItWorks).to.throwException();
- }, 'expected fn to throw an exception');
+ }, 'expected anonItWorks to throw an exception');
if (nameSupported) {
err(function () {
expect(itWorks).to.throwException();
}, 'expected itWorks to throw an exception');
--
2.9.3

23
dl-tests.sh Normal file
View File

@ -0,0 +1,23 @@
#!/bin/bash
tag=0.2.0
set -e
tmp=$(mktemp -d)
trap cleanup EXIT
cleanup() {
set +e
[ -z "$tmp" -o ! -d "$tmp" ] || rm -rf "$tmp"
}
unset CDPATH
pwd=$(pwd)
pushd "$tmp"
git clone https://github.com/LearnBoost/expect.js.git
cd expect.js
git archive --prefix="test/" --format=tar tags/${tag}:test/ \
| bzip2 > "$pwd"/tests-${tag}.tar.bz2
popd

BIN
expect.js-0.2.0.tgz Normal file

Binary file not shown.

View File

@ -0,0 +1,58 @@
From bc56c15ecaad15a48de189bf9de80b4a59ae70c1 Mon Sep 17 00:00:00 2001
From: Gavin Huang <gravof@gmail.com>
Date: Tue, 25 Sep 2012 13:13:37 +0800
Subject: [PATCH 06/13] Add 'actual' & 'expected' property to the thrown error
---
expect.js | 18 +++++++++++++-----
1 file changed, 13 insertions(+), 5 deletions(-)
diff --git a/expect.js b/expect.js
index ac14ea8..776fc8c 100644
--- a/expect.js
+++ b/expect.js
@@ -91,12 +91,18 @@
* @api private
*/
- Assertion.prototype.assert = function (truth, msg, error) {
+ Assertion.prototype.assert = function (truth, msg, error, expected) {
var msg = this.flags.not ? error : msg
- , ok = this.flags.not ? !truth : truth;
+ , ok = this.flags.not ? !truth : truth
+ , err;
if (!ok) {
- throw new Error(msg.call(this));
+ err = new Error(msg.call(this));
+ if (arguments.length > 3) {
+ err.actual = this.obj
+ err.expected = expected
+ }
+ throw err
}
this.and = new Assertion(this.obj);
@@ -200,7 +206,8 @@
this.assert(
obj === this.obj
, function(){ return 'expected ' + i(this.obj) + ' to equal ' + i(obj) }
- , function(){ return 'expected ' + i(this.obj) + ' to not equal ' + i(obj) });
+ , function(){ return 'expected ' + i(this.obj) + ' to not equal ' + i(obj) }
+ , obj);
return this;
};
@@ -214,7 +221,8 @@
this.assert(
expect.eql(obj, this.obj)
, function(){ return 'expected ' + i(this.obj) + ' to sort of equal ' + i(obj) }
- , function(){ return 'expected ' + i(this.obj) + ' to sort of not equal ' + i(obj) });
+ , function(){ return 'expected ' + i(this.obj) + ' to sort of not equal ' + i(obj) }
+ , obj);
return this;
};
--
1.8.2.1

View File

@ -0,0 +1,27 @@
From a17b21199149014a26729e79331001f976c9ee81 Mon Sep 17 00:00:00 2001
From: Gavin Huang <gravof@gmail.com>
Date: Tue, 25 Sep 2012 12:33:55 +0800
Subject: [PATCH 05/13] Pass .fail() unit test
---
expect.js | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/expect.js b/expect.js
index ab5a1ee..ac14ea8 100644
--- a/expect.js
+++ b/expect.js
@@ -466,8 +466,8 @@
* @api public
*/
Assertion.prototype.fail = function (msg) {
- msg = msg || "explicit failure";
- this.assert(false, msg, msg);
+ var error = function() { return msg || "explicit failure"; }
+ this.assert(false, error, error);
return this;
};
--
1.8.2.1

55
nodejs-expect-dot-js.spec Normal file
View File

@ -0,0 +1,55 @@
%{?nodejs_find_provides_and_requires}
%global enable_tests 1
Name: nodejs-expect-dot-js
Version: 0.2.0
Release: 1
Summary: Behavior-driven development (BDD) style assertions for Node.js and the browser
License: MIT
URL: https://npmjs.org/package/expect.js
Source0: http://registry.npmjs.org/expect.js/-/expect.js-%{version}.tgz
# Source1 is generated by running Source10, which pulls from the upstream
# revision control repository.
Source1: tests-0.2.0.tar.bz2
Source10: dl-tests.sh
BuildArch: noarch
ExclusiveArch: %{nodejs_arches} noarch
Patch0: %{name}-0.2.0-Pass-.fail-unit-test.patch
Patch1: %{name}-0.2.0-Add-actual-expected-property-to-the-thrown-error.patch
BuildRequires: nodejs-packaging
%if 0%{?enable_tests}
BuildRequires: npm(mocha)
%endif
Patch2: 0001-Update-expected-test-values.patch
%description
%{summary}.
%prep
%setup -q -n package
%setup -q -D -T -a 1 -n package
%patch0 -p1
%patch1 -p1
%patch2 -p1
%build
%install
mkdir -p %{buildroot}%{nodejs_sitelib}/expect.js
cp -pr package.json expect.js \
%{buildroot}%{nodejs_sitelib}/expect.js
%nodejs_symlink_deps
%if 0%{?enable_tests}
%check
%nodejs_symlink_deps --check
%{nodejs_sitelib}/mocha/bin/mocha --require ./test/common \
--reporter dot --growl test/expect.js
%endif
%files
%doc History.md README.md
%{nodejs_sitelib}/expect.js
%changelog
* Fri Aug 21 2020 leiju <leiju4@huawei.com> - 0.2.0-1
- Package init

View File

@ -0,0 +1,4 @@
version_control: github
src_repo: Automattic/expect.js
tag_prefix: "^"
seperator: "."

BIN
tests-0.2.0.tar.bz2 Normal file

Binary file not shown.