|
940 | 940 | "script": {
|
941 | 941 | "id": "97ad4eef-99b5-4a4d-896e-7e63d3bd14ab",
|
942 | 942 | "exec": [
|
| 943 | + "", |
| 944 | + "const responseJson = pm.response.json();", |
| 945 | + "", |
| 946 | + "let moves = responseJson.moves;", |
| 947 | + "", |
| 948 | + "let game = [];", |
| 949 | + "", |
| 950 | + "let previous_move = { \"one\": \" \", \"two\": \" \", \"three\": \" \", \"four\": \" \", \"five\": \" \", \"six\": \" \", \"seven\": \" \", \"eight\": \" \", \"nine\": \" \"};", |
| 951 | + "", |
| 952 | + "for(let i = 0; i < moves.length; i++){", |
| 953 | + " ", |
| 954 | + " let player = moves[i].player === 1 ? 'X' : 'O';", |
| 955 | + " ", |
| 956 | + " let this_move = {", |
| 957 | + " \"one\": moves[i].square === 0 ? player : previous_move.one,", |
| 958 | + " \"two\": moves[i].square === 1 ? player : previous_move.two,", |
| 959 | + " \"three\": moves[i].square === 2 ? player : previous_move.three,", |
| 960 | + " \"four\": moves[i].square === 3 ? player : previous_move.four,", |
| 961 | + " \"five\": moves[i].square === 4 ? player : previous_move.five,", |
| 962 | + " \"six\": moves[i].square === 5 ? player : previous_move.six,", |
| 963 | + " \"seven\": moves[i].square === 6 ? player : previous_move.seven,", |
| 964 | + " \"eight\": moves[i].square === 7 ? player : previous_move.eight,", |
| 965 | + " \"nine\": moves[i].square === 8 ? player : previous_move.nine", |
| 966 | + " };", |
| 967 | + " previous_move = this_move;", |
| 968 | + " game.push(this_move);", |
| 969 | + "}", |
| 970 | + "", |
| 971 | + "let tmplt = `", |
| 972 | + " <style>", |
| 973 | + " td.btm-rt {", |
| 974 | + " border-right: 2px solid blue;", |
| 975 | + " border-bottom: 2px solid blue;", |
| 976 | + " }", |
| 977 | + " td.btm {", |
| 978 | + " border-bottom: 2px solid blue;", |
| 979 | + " }", |
| 980 | + " td.lf-rt {", |
| 981 | + " border-right: 2px solid blue;", |
| 982 | + " border-left: 2px solid blue;", |
| 983 | + " }", |
| 984 | + " td {", |
| 985 | + " padding: 10px; ", |
| 986 | + " width: 2em; ", |
| 987 | + " height: 2em;", |
| 988 | + " font-size:2em;", |
| 989 | + " text-align:center;", |
| 990 | + " vertical-align: center;", |
| 991 | + " }", |
| 992 | + " </style>", |
| 993 | + " {{#each response}}", |
| 994 | + " <table>", |
| 995 | + " <tr><td class=\"btm-rt\">{{one}}</td><td class=\"btm-rt\">{{two}}</td><td class=\"btm\">{{three}}</td></tr>", |
| 996 | + " <tr><td class=\"btm-rt\">{{four}}</td><td class=\"btm-rt\">{{five}}</td><td class=\"btm\">{{six}}</td></tr>", |
| 997 | + " <tr><td>{{seven}}</td><td class=\"lf-rt\">{{eight}}</td><td>{{nine}}</td></tr>", |
| 998 | + " </table>", |
| 999 | + " <br />", |
| 1000 | + "{{/each}}`;", |
| 1001 | + " ", |
| 1002 | + "pm.visualizer.set(tmplt, {response: game});", |
| 1003 | + "", |
943 | 1004 | "pm.test(\"Status code is 200\", () => {",
|
944 | 1005 | " pm.response.to.have.status(200);",
|
945 | 1006 | "});",
|
946 | 1007 | "",
|
947 |
| - "const responseJson = pm.response.json();", |
948 |
| - "", |
949 | 1008 | "const game_id = pm.environment.get(\"happy_path_game_id\");",
|
950 | 1009 | "",
|
951 | 1010 | "pm.test(`The game id is ${game_id}`, () => {",
|
|
0 commit comments