Skip to content

Commit 14d266d

Browse files
committed
feat(test): LAR-188 add test
1 parent 411b95c commit 14d266d

File tree

8 files changed

+184
-247
lines changed

8 files changed

+184
-247
lines changed

app-modules/gamify/src/Models/.gitkeep

Whitespace-only changes.

app-modules/gamify/tests/.gitkeep

Whitespace-only changes.

app-modules/gamify/tests/CreatesUsers.php

Lines changed: 0 additions & 34 deletions
This file was deleted.

app-modules/gamify/tests/Feature/ReputationTest.php

Lines changed: 20 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,8 @@
22

33
declare(strict_types=1);
44

5-
use App\Models\User;
65
use Laravelcm\Gamify\Models\Reputation;
76

8-
/**
9-
* @var \Tests\TestCase $this
10-
*/
11-
beforeEach(function (): void {
12-
$this->user = $this->login();
13-
});
14-
157
describe(Reputation::class, function (): void {
168

179
it('gets user points', function (): void {
@@ -20,31 +12,33 @@
2012
expect($user->getPoints())->toBe(10);
2113
});
2214

23-
// it('gives reputation point to a user', function (): void {
24-
// $user = User::factory()->create();
15+
it('gives reputation point to a user', function (): void {
16+
$user = $this->createUser();
2517

26-
// expect($user->getPoints())->toBe(0);
18+
expect($user->getPoints())->toBe(0);
2719

28-
// $user->addPoint(10);
20+
$user->addPoint(10);
2921

30-
// expect($user->fresh()->getPoints())->toBe(10);
31-
// });
22+
expect($user->fresh()->getPoints())->toBe(10);
23+
});
3224

33-
// it('reduces reputation point for a user', function (): void {
34-
// $user = User::factory()->create(['reputation' => 20]);
35-
// expect($user->reputation)->toBe(20);
25+
it('reduces reputation point for a user', function (): void {
26+
$user = $this->createUser(['reputation' => 20]);
3627

37-
// $user->reducePoint(5);
28+
expect($user->reputation)->toBe(20);
3829

39-
// expect($user->fresh()->getPoints())->toBe(15);
40-
// });
30+
$user->reducePoint(5);
4131

42-
// it('zeros reputation point of a user', function (): void {
43-
// $user = User::factory()->create(['reputation' => 50]);
44-
// expect($user->getPoints())->toBe(50);
32+
expect($user->fresh()->getPoints())->toBe(15);
33+
});
4534

46-
// $user->resetPoint();
35+
it('zeros reputation point of a user', function (): void {
36+
$user = $this->createUser(['reputation' => 50]);
4737

48-
// expect($user->fresh()->getPoints())->toBe(0);
49-
// });
38+
expect($user->getPoints())->toBe(50);
39+
40+
$user->resetPoint();
41+
42+
expect($user->fresh()->getPoints())->toBe(0);
43+
});
5044
});

app-modules/gamify/tests/Pest.php

Lines changed: 0 additions & 7 deletions
This file was deleted.

app-modules/gamify/tests/TestCase.php

Lines changed: 0 additions & 17 deletions
This file was deleted.

0 commit comments

Comments
 (0)